import { Route, Redirect } from 'react-router-dom'
import { isAust } from '@/utils/token'
// ...rest 剩余参数   拿到除了component的所有传过来的参数
export const AuthRoute = ({ component: Component, ...rest }) => {
  return (
    <Route
      {...rest}
      render={(props) => {
        const isLogin = isAust()
        if (isLogin) {
          return <Component></Component>
        } else {
          return (
            <Redirect
              to={{
                pathName: '/Login',
                state: {
                  from: props.location.pathname,
                },
              }}
            />
          )
        }
      }}
    />
  )
}
